<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use think\Cookie;
class Order extends Common
{
   public function cycle(){
        if(Cookie::has('userInfo')==false) {
			$res['code']=1004;
			$res['msg']="登录超时！请重新登录";
        }else{
			$userInfo=Cookie::get('userInfo');
			Cookie::set('userInfo',$userInfo,7200);
			$memberId=$userInfo['id'];
			$cycle=input('post.cycle');
			$url=config('tdwApi')."/order/changeAmount.jhtml?memberId=$memberId&cycle=$cycle";
			$res=$this->http($url);
			$res=json_decode($res[0],true);			
		}
		echo json_encode($res);	   
   }
   public function payment(){
        if(Cookie::has('userInfo')==false){
			$res['code']=1004;
			$res['msg']="登录超时！请重新登录";
        }else{
			$userInfo=Cookie::get('userInfo');
			Cookie::set('userInfo',$userInfo,7200);
			$data['memberId']=$userInfo['id'];
			$data['cycle']=input('post.cycle');
			$data['areaId']=input('post.areaId');
			$data['address']=input('post.address');
			$data['phone']=input('post.phone');
			$data['consignee']=input('post.consignee');
			$data['paymentPluginId']=input('post.pay');
			$data['shippingMethodId']=input('post.shippingMethods');
			$url=config('tdwApi')."/order/create.jhtml";
			$res=$this->https_post($url,$data);
			$res=json_decode($res,true);
		}
		echo json_encode($res);		
   }
   public function orderInfoPay(){
        if(Cookie::has('userInfo')==false){
			$res['code']=1004;
			$res['msg']="登录超时！请重新登录";
        }else{
			$userInfo=Cookie::get('userInfo');
			Cookie::set('userInfo',$userInfo,7200);
			$data['memberId']=$userInfo['id'];
			$data['phone']=input('post.phone');
			$data['sn']=input('post.sn');
			$data['consignee']=input('post.consignee');
			$data['paymentPluginId']=input('post.pay');
			$url=config('tdwApi')."/payment/submit.jhtml";
			$res=$this->https_post($url,$data);
			$res=json_decode($res,true);			
		}
		echo json_encode($res);		   
   }
   public function integralPost(){
        if(Cookie::has('userInfo')==false){
			$res['code']=1004;
			$res['msg']="登录超时！请重新登录";
        }else{
			$userInfo=Cookie::get('userInfo');
			Cookie::set('userInfo',$userInfo,7200);
			$data['memberId']=$userInfo['id'];
			$data['phone']=input('post.mobile');
			$data['productId']=input('post.productId');
			$data['areaId']=input('post.areaId');
			$data['address']=input('post.address');
			$data['consignee']=input('post.name');
			$data['quantity']=input('post.quantity');
			$url=config('tdwApi')."/exchangeRecord/create.jhtml";
			$res=$this->https_post($url,$data);
			$res=json_decode($res,true);			
		}
		echo json_encode($res);	   
   }
   
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
